package com.seeyon.apps.ext.kingdee.controller;


import com.seeyon.apps.ext.kingdee.json.JSONObject;
import com.seeyon.apps.ext.kingdee.manager.kingdeeManager;
import com.seeyon.apps.ext.kingdee.util.RocResponse;
import com.seeyon.apps.ext.kingdee.util.StringUtil;
import com.seeyon.apps.ext.kingdee.util.TXWebUtil;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.controller.BaseController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class Down1Controller extends BaseController {

    private com.seeyon.apps.ext.kingdee.manager.kingdeeManager kingdeeManager;
    public com.seeyon.apps.ext.kingdee.manager.kingdeeManager getkingdeeManager() {
        if (kingdeeManager == null) {
            kingdeeManager = (kingdeeManager) AppContext.getBean("kingdeeManager");
        }
        return kingdeeManager;
    }


    @Override
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        /*JSP file path:ApacheJetspeed\webapps\seeyon\WEB-INF\jsp\apps\ext\kingdee\kingdee.jsp*/
        String bizId = request.getParameter("bizId");
       if (StringUtil.isEmpty(bizId))
        {
            TXWebUtil.print(new JSONObject( RocResponse.error(-1,"参数错误")).toString(), response);
            return null;
        }
        String docName = request.getParameter("docName");

        String docName2 = request.getParameter("docName2");
        kingdeeManager kingdeeManager = getkingdeeManager();
        TXWebUtil.print( new JSONObject(RocResponse.success(kingdeeManager.geAttachment(bizId,docName,docName2))).toString(), response);
        return null;
    }




}